package com.openx.cloud.server.autoconfigure.security.oauth2;

import com.openx.cloud.server.autoconfigure.security.SecurityInfo;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.provider.TokenRequest;

/**
 * @author yadu
 */
public interface UserTokenAuthenticationHandler {

    /**
     * 处理认证
     *
     * @param tokenRequest
     * @return
     */
    SecurityInfo authenticate(TokenRequest tokenRequest);

    /**
     * 进行预处理
     *
     * @param tokenRequest
     */
    void prepare(TokenRequest tokenRequest);

    /**
     * 认证成功后
     *
     * @param tokenRequest
     * @param authentication
     */
    void success(TokenRequest tokenRequest, Authentication authentication);

    /**
     * 判断是否支持认证类型
     *
     * @param request
     * @return
     */
    boolean support(TokenRequest request);


}
